package com.util;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import com.bean.Bargain;
import com.bean.Indent;



public class Export2{
	   
      
    public void buildBaojiaExcel(List list, String sheetname, OutputStream out) {  
                  
        HSSFWorkbook wb = new HSSFWorkbook();  
        HSSFSheet sheet1 = wb.createSheet("sheet1");  
        HSSFRow row = sheet1.createRow((short) 0);  
        row.createCell(0).setCellValue("ID");  
        row.createCell(1).setCellValue("房间");  
        row.createCell(2).setCellValue("客户名称");  
        row.createCell(3).setCellValue("甲方名称");  
        row.createCell(4).setCellValue("业务员名称"); 
        row.createCell(5).setCellValue("订单编号"); 
        row.createCell(6).setCellValue("协议总价"); 
        row.createCell(7).setCellValue("房间单价");
        row.createCell(8).setCellValue("付款方式");
        row.createCell(9).setCellValue("签订时间");
        row.createCell(10).setCellValue("合同内容");
  
          
        for (int i = 0; i < list.size(); i++) {  
        	 Bargain s = (Bargain)list.get(i);  
            row=sheet1.createRow((short)(i+1));  
            row.createCell(0).setCellValue(s.getId());  
            row.createCell(1).setCellValue(s.getComplex()+"#"+s.getUnit()+"#"+s.getRoomname());  
            row.createCell(2).setCellValue(s.getCname());  
            row.createCell(3).setCellValue(s.getJname());  
            row.createCell(4).setCellValue(s.getUname());
            row.createCell(5).setCellValue(s.getMaketingid());
            row.createCell(6).setCellValue(s.getRoomtotal());
            row.createCell(7).setCellValue(s.getRoomprice());
            row.createCell(8).setCellValue(s.getPaymenttypeid());
            row.createCell(9).setCellValue(s.getSignedtime().toLocaleString());
            row.createCell(10).setCellValue(s.getContent());  
        }  
        try {  
            out.flush();  
            wb.write(out);  
            out.close();          
  
        } catch (IOException e) {  
            e.printStackTrace();  
            System.out.println("Out  is  closed ");  
        }  
    }
}
